package com.hdax.entity;

import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * <p>
 * 试驾表
 * </p>
 *
 * @author ${author}
 * @since 2021-03-22
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("cus_drive")
public class CusDrive implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 编号
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    /**
     * 客户编号
     */
    @TableField("cus_id")
    private Integer cusId;

    /**
     * 员工编号
     */
    @TableField("user_id")
    private Integer userId;

    /**
     * 试驾人姓名
     */
    @TableField("drive_name")
    private String driveName;

    /**
     * 手机号
     */
    @TableField("phone")
    private String phone;

    /**
     * 试驾车编号
     */
    @TableField("car_id")
    private Integer carId;

    /**
     * 试驾时间
     */
    @TableField("drive_time")
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime driveTime;

    /**
     * 试驾类型
     */
    @TableField("drive_type")
    private Integer driveType;

    /**
     * 是否主体验人
     */
    @TableField("`primary`")
    private boolean primary;

    /**
     * 身份证资源
     */
    @TableField("IDCardSource")
    private String IDCardSource;

    /**
     * 驾驶证资源
     */
    @TableField("driveCardSource")
    private String driveCardSource;

    /**
     * 备注信息
     */
    @TableField("notes")
    private String notes;

    /**
     * 取消
     */
    @TableField("cancel")
    private String cancel;

    /**
     * 创建时间
     */
    @TableField("create_time")
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private LocalDateTime createTime;

    /**
     * 修改时间
     */
    @TableField("update_time")
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private LocalDateTime updateTime;

    /**
     * 创建人编号
     */
    @TableField("create_user_id")
    private Integer createUserId;

    /**
     * 最后修改人编号
     */
    @TableField("update_user_id")
    private Integer updateUserId;

    @TableField(exist = false)
    private Customer customer;

    @TableField(exist = false)
    private String stringDriveType;

    @TableField(exist = false)
    private String carSeries;

    public String getFormattedDate() {
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        return driveTime.format(formatter);
    }
}
